package com.song.mapper;


import com.song.pojo.Emp;
import com.song.pojo.EmpExpr;
import com.song.pojo.EmpQueryParam;
import com.song.pojo.JobOption;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {


/* 查询列表名称
    @Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id order by e.update_time desc limit #{index},#{size}")
    public List<Emp> list(Integer index,Integer size);
*/


/*    查询总记录数
    @Select("select count(*) from emp e left join dept d on e.dept_id = d.id")
    public Long count();
*/
/*    @Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id order by e.update_time desc") */
//    public List<Emp> list(String name, Integer gender, LocalDate startDate, LocalDate endDate);
    public List<Emp> list(EmpQueryParam param);

//    @Options(useGeneratedKeys = true,keyProperty = "id")
    void addEmp(Emp emp);



    void addEmpExpr(List<EmpExpr> list);

//    @Delete("delete from emp where id in #{ids}")
    void deleteByIds(List<Integer> ids);

//    @Delete("delete from emp_expr where emp_id in #{ids}")
    void deleteEmpExprByIds(List<Integer> ids);



    Emp findById(Integer id);



    void updateEmp(Emp emp);

    @MapKey("job")
    List<Map<String,Object>> getJobOption();

    @MapKey("name")
    List<Map<String, Object>> getGenderCount();

    @Select("select id,name,username from emp where username = #{username} and password = #{password}")
    Emp findByUsernameAndPassword(Emp emp);
}
